|
TuplesA tuple is a fixed-length sequence of values that may have different types. Tuples are constructed by listing their components in parentheses:
Unlike lists, tuples cannot grow or shrink, and their element types need not be uniform. The empty tupleThe empty tuple
Accessing componentsFor pairs, the built-in accessor functions are: fst :: (a, b) -> a (Prelude) Gives the first element of a pair. snd :: (a, b) -> b (Prelude) Gives the second element of a pair. For longer tuples, use pattern matching:
Pattern matching on tuplesTuples are deconstructed with pattern matching in function arguments,
Higher-order utilitiescurry :: ((a, b) -> <d> c) -> a -> b -> <d> c (Prelude) Transforms a function taking a pair as a parameter to a function taking two values as a parameter. uncurry :: (a -> b -> <d> c) -> (a, b) -> <d> c (Prelude) Transforms a function two values as a parameter to a function taking a pair as a parameter.
|